package com.fyzk.activity.lottery.shuzicai;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.fyzk.activity.app.ActivityTaskManager;
import com.fyzk.base.BaseActivity;
import com.fyzk.activity.app.AppToast;
import com.fyzk.activity.myview.DrawBallFrameLayout;
import com.fyzk.activity.prize.JLPrizeActivity;
import com.fyzk.activity.prize.JZPrizeActivity;
import com.fyzk.activity.prize.NumberLotteryPrizeHistroyActivity;
import com.fyzk.activity.user.LoginActivity;
import com.fyzk.activity.user.touzhu.CommonBetActivity;
import com.fyzk.activity.zhifu.NumLotteryZhiFuActivity;
import com.fyzk.bean.CurrentPhaseInfo;
import com.fyzk.bean.HistoryPrizeResponse;
import com.fyzk.bean.MissValueBean;
import com.fyzk.bean.MissValueListBean;
import com.fyzk.bean.PrizeHistoryItem;
import com.fyzk.betcode.AppLotteryCodeListManager;
import com.fyzk.betcode.BetLotteryInfo;
import com.fyzk.betcode.CodeBase;
import com.fyzk.betcode.CodeFactory;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.data.preference.MySharedPreferences;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.fyzk.net.Commands;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.utils.LogUtil;
import com.fyzk.utils.LogUtils;
import com.fyzk.utils.LotteryIDUtils;
import com.fyzk.utils.MyZhenDong;
import com.fyzk.utils.YaoYiYao;
import com.fyzk.utils.YaoYiYao.OnShakeListener;
import com.fyzk.view.DownMenuPopupwindow;
import com.fyzk.view.LotteryCountDown;
import com.fyzk.view.TopTitleView;
import com.fyzk.view.ViewCallBack;
import com.fyzk.view.ViewCallBack.CountDownInterface;
import com.tyjc.lottery.R;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import http.Common.CommandUtil;
import com.wf.domain.UrlDef;
import http.StringResultBean;

public abstract class LotteryBaseActivity extends BaseActivity implements
        OnClickListener, onTopTitleClickListener, CountDownInterface,
        OnShakeListener, DrawBallFrameLayout.UpOrDownListener, DownMenuPopupwindow.DownMenuPopupItemListener,
        TouZhuHelper.BallClickListener, TouZhuHelper.BallItemClickLitener {

    protected LotteryCountDown endTiem_and_phase;

    private TextView bottom_xuanding;
    private TextView bottom_clear;

    protected boolean isYao = true;

    protected int position = 0;
    protected int popupId = 0;
    protected List<List<BallInfo>> arr_infos = new ArrayList<List<BallInfo>>();

    public abstract boolean touZhu();

    protected final int maxZhuShu = 10000;

    protected MissValueBean missInfo;

    protected String missKey = "2007MV_RX";
    protected String[] labels = {"miss"};

    private TextView down_up_line_tv;

    private DownMenuPopupwindow downMenu;

    public void touZhu1(int wcodeId, long zhuShu) {
        if (zhuShu > maxZhuShu) {
            AppToast.getToast().show("单笔彩金不得超过" + (maxZhuShu * 2) + "米");
            return;
        }
        if (position >= 0) {
            AppLotteryCodeListManager.getInstance().getList().remove(position);
        }
        CodeBase codeObj = CodeFactory.getCode(wcodeId);
        String Zhuma = codeObj.betCode(arr_infos);
        String showZhuMa = codeObj.formatHtmlCode2(Zhuma);
        AppLotteryCodeListManager.getInstance().AddLotteryInfo(wcodeId, Zhuma,
                showZhuMa, zhuShu, arr_infos, popupId);
        BetLotteryInfo betInfo = new BetLotteryInfo(wcodeId, Zhuma, showZhuMa,
                zhuShu, arr_infos, popupId);
        Intent intent = new Intent(this, NumLotteryZhiFuActivity.class);
        intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
        intent.putExtra("bet", (Serializable) betInfo);
        startActivity(intent);
    }

    public void touZhu1(int wcodeId, long zhuShu, boolean isToActivity) {
        if (zhuShu > maxZhuShu) {
            AppToast.getToast().show("单笔彩金不得超过" + (maxZhuShu * 2) + "米");
            return;
        }
        if (position >= 0) {
            AppLotteryCodeListManager.getInstance().getList().remove(position);
        }
        CodeBase codeObj = CodeFactory.getCode(wcodeId);
        String Zhuma = codeObj.betCode(arr_infos);
        String showZhuMa = codeObj.formatHtmlCode2(Zhuma);
        AppLotteryCodeListManager.getInstance().AddLotteryInfo(wcodeId, Zhuma,
                showZhuMa, zhuShu, arr_infos, popupId);
        BetLotteryInfo betInfo = new BetLotteryInfo(wcodeId, Zhuma, showZhuMa,
                zhuShu, arr_infos, popupId);
        if (isToActivity) {
            LogUtil.e("" + AppLotteryCodeListManager.getInstance().getList().size());
            Intent intent = new Intent(this, NumLotteryZhiFuActivity.class);
            intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
            intent.putExtra("bet", (Serializable) betInfo);
            startActivity(intent);
        }
    }

    public abstract void clear();

    public abstract int getLotteryId();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        ViewCallBack.getInstance().AttachCountDownObj(this);
        YaoYiYao.getInstance().setOnShakeListener(this);
        addArrayInfors();

        downMenu = new DownMenuPopupwindow(this,
                AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT,
                getMenuItems());
        downMenu.setDownMenuPopupOnItemListener(this);

        List<BetLotteryInfo> infos = (List<BetLotteryInfo>) MySharedPreferences.getInstance().getBetCodeBean(getLotteryId());
        if (infos != null && infos.size() > 0) {
            AppToast.getToast().show("这是您上次保存的号码");
            AppLotteryCodeListManager.getInstance().setList(infos);
            Intent intent = new Intent(this, NumLotteryZhiFuActivity.class);
            intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
            startActivity(intent);
        }
    }

    protected String[] getMenuItems() {
        return new String[]{"开奖公告", "走势图", "玩法介绍", "投注查询"};
    }

    public static final String ID = "id";

    private void addArrayInfors() {
        List<BetLotteryInfo> infos = AppLotteryCodeListManager.getInstance()
                .getList();
        position = getIntent().getIntExtra(ID, -1);
        popupId = getIntent().getIntExtra("popup", 0);
        if (infos != null && infos.size() > 0 && position >= 0) {
            // arr_infos = infos.get(position).arr_infos;
            for (int i = 0; i < infos.get(position).arr_infos.size(); i++) {
                List<BallInfo> ballInfos = infos.get(position).arr_infos.get(i);
                List<BallInfo> ballInfos2 = new ArrayList<BallInfo>();
                for (int j = 0; j < ballInfos.size(); j++) {
                    ballInfos2.add((BallInfo) ballInfos.get(j).clone());
                }
                arr_infos.add(ballInfos2);
            }

            popupId = infos.get(position).popupID;
        }
    }

    protected abstract void popupClickItem(int arg2);

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        YaoYiYao.getInstance().stop();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        net();
        YaoYiYao.getInstance().start();
//        addHistoryView(null, false);
        try {
            down_up_line_tv = (TextView) findViewById(R.id.down_up_line_tv);
        } catch (Exception e) {

        }
        // 投注号码
        switch (AppLotteryCodeListManager.betType) {
            case AppLotteryCodeListManager.FIRSTENTER:
                clear();
                break;
            case AppLotteryCodeListManager.ADDCODE:
                clear();
                break;
            case AppLotteryCodeListManager.MODIFICATIONCODE:
                popupId = AppLotteryCodeListManager.getInstance().getList().get(AppLotteryCodeListManager.chooseId).popupID;
                popupClickItem(popupId);
                arr_infos = AppLotteryCodeListManager.getInstance().getList().get(AppLotteryCodeListManager.chooseId).arr_infos;
                initArrayInfos();
                AppLotteryCodeListManager.getInstance().getList().remove(AppLotteryCodeListManager.chooseId);
                ballClick();
                break;
            case AppLotteryCodeListManager.OKTOBACK:
                clear();
                break;
            case AppLotteryCodeListManager.SAVECODE:
                finish();
                break;
        }
    }

    protected void initArrayInfos() {

    }

    @Override
    protected void onDestroy() {
        AppLotteryCodeListManager.betType = AppLotteryCodeListManager.FIRSTENTER;
        AppLotteryCodeListManager.getInstance().getList().clear();
        AppLotteryCodeListManager.chooseId = 0;
        TouZhuHelper.getInstance().detachBallItemClickListener(this);
        TouZhuHelper.getInstance().detachBallClickListener(this);
        ViewCallBack.getInstance().DettachCountDownObj(this);
        LogUtil.v("TouZhuHelper剩余个数" + TouZhuHelper.getInstance().size());
        YaoYiYao.getInstance().clear();
        super.onDestroy();
    }


    protected void net() {
        // 请网
        getMissValueList();
        findCurrentPhase();
    }


    protected abstract void addHistoryView(
            ArrayList<PrizeHistoryItem> historyItems, boolean isWaitting);

    @Override
    protected void onSuccess(int requestCode, StringResultBean resultBean, String result) {
        super.onSuccess(requestCode, resultBean, result);
        switch (requestCode) {
            case CommandUtil.FINDCURRENTPHASE:

                LogUtils.e("====result===="+result);

                CurrentPhaseInfo info = JSON.parseObject(resultBean.getData(),
                        CurrentPhaseInfo.class);
                getPhaseStatus = 1;
                AppLotteryInfos.setCurrentPrizeInfo(info);
                boolean isNowPhase = AppLotteryInfos.period_buffer.toString().contains(
                        AppLotteryInfos.getPeriod(getLotteryId()) + getLotteryId());
                if (!isNowPhase) {
                    getMissValue();
                }
                break;
            case CommandUtil.HISTORY_LOTTERY:
                prizeResponse = JSON.parseObject(resultBean.getData(),
                        HistoryPrizeResponse.class);
                addHistoryView(prizeResponse.wincodes, isWaitting);

                break;
            case CommandUtil.PHASEMVLISTDATA:
                if (resultBean.getErrorcode().equals("0")) {
                    missInfo = JSON.parseObject(result,
                            MissValueBean.class);
                    addMissValue(); // 显示遗漏
                    getMissStatus = 1;
                } else {
                    getMissStatus = -1;
                }
                break;
        }

    }

    private MissValueListBean missValueListBean;    // 多期遗漏（11x5）
    private HistoryPrizeResponse prizeResponse;     // 开奖信息

    /**
     * 添加遗漏值
     */
    protected void addMissValue() {

    }

    /**
     * 设置获取多期遗漏 所需的key
     *
     * @param missKey
     * @param labels  解析所需的标签集合: miss,ge,shi,bai等。。
     */
    protected void setMissKey(String missKey, String[] labels) {
        this.missKey = missKey;
        this.labels = labels;
    }

    @Override
    protected void onFailure(int requestCode, String error, String message) {
        switch (requestCode) {
            case CommandUtil.HISTORY_LOTTERY:
                break;
            case CommandUtil.FINDCURRENTPHASE:
                if (error.equals("900003")) {
                    getPhaseStatus = -1;
                } else {
                    showToast(message);
                }
                break;
            case CommandUtil.PHASEMVLISTDATA:
                getMissStatus = -1;
                break;
        }
    }

    /**
     * 初始化 小球list
     *
     * @param balls
     * @param count 每列显示小球数
     * @param start
     */
    public void initBallList(List<BallInfo> balls, int count, int start,
                             boolean hasZero) {
        balls.clear();
        for (int j = start; j < count + start; j++) {
            BallInfo qiu;
            if (hasZero) {
                if (j < 10) {
                    qiu = new BallInfo("0" + j);
                } else {
                    qiu = new BallInfo("" + j);
                }
            } else {
                qiu = new BallInfo(String.valueOf(j));
            }
            balls.add(qiu);
        }
    }

    /**
     * 初始化 小球list
     *
     * @param balls
     * @param count 每列显示小球数
     * @param start
     */
    public void initBallList(List<BallInfo> balls, int count, int start,
                             String[] prizes) {
        balls.clear();
        for (int j = start; j < count + start; j++) {
            BallInfo qiu;
            qiu = new BallInfo(String.valueOf(j));
            if (prizes.length == count) {
                qiu.prize = prizes[j - start];
            }
            balls.add(qiu);
        }
    }

    /**
     * 初始化 小球list
     *
     *
     * @param balls
     * @param count 每列显示小球数
     * @param start
     */
    public void initBallList(List<BallInfo> balls, int count, int start) {
        balls.clear();
        for (int j = start; j < count + start; j++) {
            BallInfo qiu;
            qiu = new BallInfo(String.valueOf(j));

            balls.add(qiu);
        }
    }

    boolean isWaitting = false;

    private int seconds = 0;

    /**
     * 获取开奖信息
     */
    private void getKaiJiang() {
        try {
            JSONObject params = new JSONObject();
            params.put("lotteryType", getLotteryId());
            params.put("pageIndex", 1);
            params.put("maxResult", 10);//SchemaDef.HISTORY_LOTTERY
            httpPostJson(CommandUtil.HISTORY_LOTTERY, Commands.WINCODEHISTORY, params, false);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询新期
     */
    protected void findCurrentPhase() {
        if (getPhaseStatus == 0) {
            return;
        }
        getPhaseStatus = 0;
        missInfo = null;
        missValueListBean = null;
        prizeResponse = null;
        addMissValue();
        try {
            JSONObject params = new JSONObject();
            params.put("lotteryType", getLotteryId());
            httpPostJson(CommandUtil.FINDCURRENTPHASE, Commands.FINDCURRENTPHASE, params, false);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 按期查遗漏 (传当前期号)
     */
    protected void getMissValue() {
        if (getMissStatus == 0) {
            return;
        }
        getMissStatus = 0;
        try {
            JSONObject params = new JSONObject();
            params.put("lotteryType", getLotteryId());
            params.put("phase", AppLotteryInfos.getPeriod(getLotteryId()));
            httpPostJson(CommandUtil.PHASEMVLISTDATA, Commands.PHASEMVLISTDATA, params, false, UrlDef.TY_URL_NEW_DATA2);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询多期遗漏
     */
    protected void getMissValueList() {
        if (prizeResponse == null) {
            getKaiJiang();
        }
    }

    public abstract void randomBallNum();

    @Override
    public void finish() {
        // TODO Auto-generated method stub
        super.finish();
        ViewCallBack.getInstance().DettachCountDownObj(this);
    }

    public void initBottomView() {
        bottom_xuanding = (TextView) findViewById(R.id.pl5_bottom_tv_xuanding);
        bottom_clear = (TextView) findViewById(R.id.pl5_bottom_tv_clear);
        bottom_xuanding.setOnClickListener(this);
        bottom_clear.setOnClickListener(this);
    }

    @Override
    public void onLeftClick() {
        // TODO Auto-generated method stub
        finish();
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        super.onClick(v);
        switch (v.getId()) {
            case R.id.pl5_bottom_tv_xuanding:

                if (!touZhu()) {
                    AppToast.getToast().show("请先选择一注再投注");
                }
                break;
            case R.id.pl5_bottom_tv_clear:
                clear();
                break;
            default:
                break;
        }
    }

    @Override
    public void onRightClick() {
        // TODO Auto-generated method stub
    }

    @Override
    public void onRight2Click() {
        // TODO Auto-generated method stub
        net();
    }

    @Override
    public void onCenterClick() {
        // TODO Auto-generated method stub
    }

    /**
     * 设置 期号和倒计时textview
     *
     * @return
     */
    protected boolean setEndAndPhaseText() {
        return false;
    }

    int getMissStatus = 2;  // 获取遗漏值状态：-1：获取为空（或失败），0：正在获取中，1：获取成功, 2：未发送请求
    int getPhaseStatus = 2;  // 获取当前期状态：-1：获取为空（或失败），0：正在获取中，1：获取成功, 2：未发送请求
    int phaseSeconds = 0;

    @Override
    public void countDown() {

        if (getPhaseStatus == -1) { // 获取当前期失败或为空时，每隔10秒请求一次
            if (phaseSeconds % 10 == 0) {
                findCurrentPhase();
                phaseSeconds = 0;
            }
            phaseSeconds++;
        } else if (getPhaseStatus == 1 && getMissStatus == -1) { // 获取遗漏失败或为空时，每隔10秒请求一次
            if (seconds % 10 == 0) {
                getMissValue();
                seconds = 0;
            }
            seconds++;
        }

        // TODO Auto-generated method stub
        if (!setEndAndPhaseText()) {
            String endTimeStr = ViewCallBack.getInstance().refreshTimeLeft(
                    AppLotteryInfos.getEndTime(getLotteryId()));
            String qi = AppLotteryInfos.getPeriod(getLotteryId());
            boolean isGaoPin = AppLotteryInfos.isGaoPin(getLotteryId());
            if (isGaoPin) {
                try {
                    qi = "距" + qi.substring(qi.length() - 2, qi.length()) + "期";
                } catch (Exception e) {
                    // TODO: handle exception
                    qi = "距 期截止:";

                }
            } else {
                qi = "第 " + qi + " 期";
            }
            if (endTiem_and_phase == null) {
                endTiem_and_phase = (LotteryCountDown) findViewById(R.id.lotterycountdown);
                endTiem_and_phase.isGaoPin(isGaoPin);
            }
            try {
                endTiem_and_phase.setEndTime(endTimeStr);
                endTiem_and_phase.setPhase(qi);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        endTime(getLotteryId());
    }

    @Override
    protected void showEndTimeDialog(String period, boolean isShowDialog, int lotteryId) {
        net();
        super.showEndTimeDialog(period, isShowDialog, lotteryId);
    }

    public void onShake() {
        // TODO Auto-generated method stub
        if (isYao) {
            MyZhenDong myZhenDong = new MyZhenDong(getContext());
            myZhenDong.playVibrate(new long[]{100, 300}, -1);
            randomBallNum();
        }
    }

    protected TopTitleView getTopView() {
        return null;
    }

    /**
     * 进入玩法介绍
     */
    public void toHelp() {
        if (getTopView() != null) {
            downMenu.showPopupWindow(getTopView());
        } else {
            Intent intent = new Intent(getContext(), InfoDetailActivity.class);
            intent.putExtra(IntentParamUtils.TITLE, getHelpTitle());
            intent.putExtra(IntentParamUtils.URL, getHelpUrl());
            startActivity(intent);
        }
    }

    @Override
    public void onMenuItem(int position) {
//        new String[]{"开奖公告","走势图", "玩法介绍","投注查询"};
        String[] menuItems = getMenuItems();
        LogUtil.d("" + menuItems[position]);
        Intent intent = null;
        if (menuItems[position].equals("开奖公告")) {
            intent = new Intent();
            switch (getLotteryId()) {
                case LotteryIDUtils.JLSF_LOTTERY_ID_INT:
                    intent.setClass(getContext(), JLPrizeActivity.class);
                    break;
                case LotteryIDUtils.JZBF_LOTTERY_ID_INT:
                    intent.setClass(getContext(), JZPrizeActivity.class);
                    break;
                case LotteryIDUtils.ZCSFC_LOTTERY_ID_INT:
                case LotteryIDUtils.ZCRXJ_LOTTERY_ID_INT:
                case LotteryIDUtils.ZCBQC_LOTTERY_ID_INT:
                case LotteryIDUtils.ZCJQC_LOTTERY_ID_INT:
                    intent.setClass(getContext(), NumberLotteryPrizeHistroyActivity.class);
                    break;
                case LotteryIDUtils.SSQ_LOTTERY_ID_INT:
                case LotteryIDUtils.QXC_LOTTERY_ID_INT:
                case LotteryIDUtils.FC3D_LOTTERY_ID_INT:
                case LotteryIDUtils.PL3_LOTTERY_ID_INT:
                case LotteryIDUtils.PL5_LOTTERY_ID_INT:
                case LotteryIDUtils.DLT_LOTTERY_ID_INT:
                case LotteryIDUtils.QLC_LOTTERY_ID_INT:
                case LotteryIDUtils.CQSSC_LOTTERY_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_ID_INT:
                case LotteryIDUtils.GD11XUAN5_LOTTERY_ID_INT:
                case LotteryIDUtils.XJ11XUAN5_LOTTERY_ID_INT:
                case LotteryIDUtils.ANHUIK3_LOTTERY_ID_INT:
                case LotteryIDUtils.NXK3_LOTTERY_ID_INT:
                case LotteryIDUtils.JSK3_LOTTERY_ID_INT:
                case LotteryIDUtils.JLK3_LOTTERY_ID_INT:
                case LotteryIDUtils.GXK3_LOTTERY_ID_INT:
                case LotteryIDUtils.KLSF_LOTTERY_ID_INT:
                case LotteryIDUtils.GDKLSF_LOTTERY_ID_INT:
                case LotteryIDUtils.KLPK_LOTTERY_ID_INT:
                    intent.setClass(getContext(), NumberLotteryPrizeHistroyActivity.class);
                    break;
            }
            intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
        } else if (menuItems[position].equals("走势图")) {
            intent = getTrendIntent();
            if (intent == null) {
                AppToast.getToast().show("该彩种暂无走势图");
                return;
            }
            intent.putExtra(IntentParamUtils.POPUPID, popupId);
        } else if (menuItems[position].equals("玩法介绍")) {
            intent = new Intent(getContext(), InfoDetailActivity.class);
            intent.putExtra(IntentParamUtils.TITLE, getHelpTitle());
            intent.putExtra(IntentParamUtils.URL, getHelpUrl());
        } else if (menuItems[position].equals("投注查询")) {
            if (MySharedPreferences.getInstance().getLoginStatus()) {
                intent = new Intent(getContext(), CommonBetActivity.class);
                intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
            } else {
                AppLotteryInfos.clear();
                ViewCallBack.getInstance().countDownObjs.clear();
                ActivityTaskManager.getInstance().closeAllActivity();
                intent = new Intent(getContext(), LoginActivity.class);
            }
        }
        try {
            startActivity(intent);
        } catch (Exception e) {
            // TODO: handle exception
            LogUtil.v(e.getMessage());
        }
    }

    public Intent getTrendIntent() {
        return null;
    }

    @Override
    public void menuDismiss() {

    }

    @Override
    public void menuShow() {

    }

    /**
     * 设置玩法介绍的链接
     *
     * @return
     */
    public abstract String getHelpUrl();

    /**
     * 设置玩法介绍的title
     *
     * @return
     */
    public abstract String getHelpTitle();

    private boolean isRequestMiss = true;

    @Override
    public void upOrDownState(int state) {
        if (down_up_line_tv != null) {
            if (state == DrawBallFrameLayout.STATE_TOP) {
                down_up_line_tv.setBackgroundResource(R.drawable.ssq_scrolldown);
                isRequestMiss = true;
            } else {
                down_up_line_tv.setBackgroundResource(R.drawable.ssq_scrolldown_up);
                if (isRequestMiss && missValueListBean == null) {
                    getMissValueList();
                    isRequestMiss = false;
                }
            }
        }
    }

    @Override
    public void toTrend() {
        Intent intent = getTrendIntent();
        if (intent == null) {
//            AppToast.getToast().show("该彩种暂无走势图");
            return;
        } else {
            intent.putExtra(IntentParamUtils.POPUPID, popupId);
            startActivity(intent);
        }
    }
}
